using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Fly : MonoBehaviour
{
    // Start is called before the first frame update
    PlayerBasic Player;
    Rigidbody2D myRigidbody;
    void Start()
    {
        Player = GetComponentInParent<PlayerBasic>();
        myRigidbody = GetComponentInParent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        if (Player.movable)
        {
            if (Input.GetKey(KeyCode.W))
            {
                Vector2 vel = new Vector2(myRigidbody.velocity.x,Player.Runspeed);
                myRigidbody.velocity = vel;
            }
            else if (Input.GetKey(KeyCode.S))
            {
                Vector2 vel = new Vector2(myRigidbody.velocity.x, -Player.Runspeed);
                myRigidbody.velocity = vel;
            }
            else
            {
                Vector2 vel = new Vector2(myRigidbody.velocity.x, 0);
                myRigidbody.velocity = vel;
            }
        }
        
    }
}
